<template>
    <div class="recommend-box">
        <slot name="title"></slot>
        <div class="recommend-list">
            <div :class=" 'item item'+i " v-for="(item, i) in items" :key="i" @click="gotoSearch(item.title)">
                <div class="titles">
                    <span class="title main">{{ item.title }}</span>
                    <span class="title sub">{{ item.viceTitle.replace(/{|}/g,"") }}</span>
                </div>
                <div class="img">
                    <img :src="item.image">
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    props: {
        items: {
            type: Array,
            default() {
                return [];
            }
        }
    },
    methods: {
        gotoSearch(name) {
            this.$router.push({
                name: "list",
                query: {
                    q: name
                }
            });
        }
    }
};
</script>
<style lang="less" scoped>
.recommend-box {
    width: 100%;
    padding-bottom: 20px;
}
.recommend-list {
    width: 100%;
    border-top: 1px solid @99;
    border-bottom: 1px solid @99;
    box-sizing: border-box;
    &::after {
        display: block;
        content: "";
        clear: both;
    }
    .item {
        text-align: center;
        overflow: hidden;
        padding: 0px @padding-size;
        box-sizing: border-box;
        .titles {
            display: flex;
            flex-flow: row wrap;
            align-content: center;
            justify-content: center;
        }
        .title {
            display: block;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }
        .main {
            font-size: 30px;
            color: @font;
            width: 100%;
        }
        .sub {
            font-size: 24spx;
            color: @pink;
        }
    }
    .item0 {
        width: 50%;
        border-right: 1px solid @99;
        height: 360px;
        float: left;
    }
    .item1,
    .item2 {
        width: 50%;
        float: right;
        height: 180px;
    }
    .item1 {
        border-bottom: 1px solid @99;
    }
    .item3,
    .item4,
    .item5 {
        width: 100% / 3;
        float: left;
        height: 280px;
        border-top: 1px solid @99;
        border-right: 1px solid @99;
    }
    .item5 {
        border-right: none;
    }
    .item0,
    .item3,
    .item4,
    .item5 {
        .titles {
            height: 40%;
        }
        .img {
            height: 60%;
            img {
                width: 100%;
                height: 100%;
                object-fit: contain;
            }
        }
    }
    .item3,
    .item4,
    .item5 {
        img {
            padding-bottom: 20px;
            box-sizing: border-box;
        }
    }
    .item1,
    .item2 {
        .titles {
            height: 100%;
            width: 70%;
            float: left;
        }
        .img {
            height: 100%;
            width: 30%;
            float: right;
            img {
                width: 100%;
                height: 100%;
                object-fit: contain;
                object-position: center;
            }
        }
    }
}
</style>
